package com.starlink.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starlink.model.domain.UserProductCollectDO;
import com.starlink.model.request.UserProductCollectRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhanghong
 */
@Repository
public interface UserProductCollectMapper extends BaseMapper<UserProductCollectDO> {
    UserProductCollectDO selectDOById(Long id);
    List<UserProductCollectDO> selectDOList(UserProductCollectDO userProductCollect);
    int insertDO(UserProductCollectDO userProductCollect);
    int batchInsertDO(List<UserProductCollectDO> userProductCollectDOList);
    int updateDO(UserProductCollectDO userProductCollect);
    int deleteDOById(Long id);
    int deleteDOByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from user_product_collect",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") UserProductCollectRequest param);
    List<UserProductCollectDO> pageQuery(@Param("param") UserProductCollectRequest param, @Param("limit") int limit, @Param("offset") long offset);

    Long selectByBookId(@Param("mallBooksId") Long mallBooksId,@Param("userId") Long userId);

}
